package com.monkey.web.context.strategy;

import com.monkey.core.web.response.MonkeyResponseDto;
import org.springframework.data.domain.Page;

import java.util.Map;

/**
 * Project  : monkey
 * Author   : Wu Tian Qiang
 * Date     : 2016/9/1
 */
public class PageCtrlReturnValueHandler extends AbstractCtrlReturnValueHandler {
    @Override
    public boolean support(Object returnValue) {
        return returnValue instanceof Page;
    }

    @Override
    public MonkeyResponseDto handle(Object returnValue, String fieldStr) {
        Page page = (Page) returnValue;
        Map<String, Object> data = exportResultPage(fieldStr, page);
        return new MonkeyResponseDto().success("操作成功", data);
    }

}
